SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE [dbo].[usp_VerifyApplyField]
    (
      @JOL_Field_No INT ,
      @JOL_Field_VerifyStatus VARCHAR(50) ,
      @JOL_Field_VerifyUser VARCHAR(50)
    )
AS 
    DECLARE @Purpose VARCHAR(50)
    SET @Purpose = ( SELECT JOL_Field_Purpose
                     FROM   dbo.JOL_ApplyField
                     WHERE  JOL_Field_No = @JOL_Field_No
                   )
    IF RTRIM(@Purpose) = '宣讲会' 
        BEGIN
            UPDATE  dbo.JOL_Lecture
            SET     JOL_Lecture_VerifyStatus = @JOL_Field_VerifyStatus ,
                    JOL_Lecture_VerifyUser = @JOL_Field_VerifyUser ,
                    JOL_Lecture_VerifyTime = GETDATE()
            WHERE   JOL_Lecture_Purpose = @JOL_Field_No
            UPDATE  dbo.JOL_ApplyField
            SET     JOL_Field_VerifyStatus = @JOL_Field_VerifyStatus ,
                    JOL_Field_VerifyUser = @JOL_Field_VerifyUser
            WHERE   JOL_Field_No = @JOL_Field_No
        END
    ELSE 
        UPDATE  dbo.JOL_ApplyField
        SET     JOL_Field_VerifyStatus = @JOL_Field_VerifyStatus ,
                JOL_Field_VerifyUser = @JOL_Field_VerifyUser
        WHERE   JOL_Field_No = @JOL_Field_No

GO
